drop _all
capture log close
set mem 4g
set more off
set virtual on
use world_child3
set logtype text
log using world-lowess, replace


***********************************
*****	THIS DO FILE:
***********************************

* 1) produces lowess graph of predicted infant mort against mother ht, for 20% of observations for pooled sample.

***********************************
*****	MODIFY DATA FOR USE
***********************************

** keep only children with full exposure

tab infant_exp
keep if infant_exp==1

* have removed these outliers 
drop if imputed_height<120 | imputed_height>180

count

gen height100=imputed_height/100
preserve

* take 20% sample since otherwise too computationally intensive

sample 20, by(country)

***********************************
*****	DESCRIPTIVES
***********************************

* descriptives of height for 20% sample so we know outliers

sum height100, detail
sum tall2, detail /* to see what % of obs are tall2 which is 2sd away from mean */
sum short2, detail /* as above but for short2 */

bys country: sum height100, detail
bys country: sum tall2, detail 
bys country: sum short2, detail 

***********************************
*****	LOWESS
***********************************

* lowess on 20% sample:

lowess infant height100, generate(infpred)

* (1)

twoway line infpred height100, sort title("Infant mortality against mother height: lowess predictions") xtitle("Mother's Height, m") ytitle("Predicted infant mortality")

log close
exit


